$(function () {
    $('#code1_popup').on('click', function(){
      $('#code1_code').modal('show');
    });
    $('#code2_popup').on('click', function(){
      $('#code2_code').modal('show');
    });
    $('#code3_popup').on('click', function(){
      $('#code3_code').modal('show');
    });
    $('#code1_code').on('show.bs.modal', function (event) {
        $(this).css('display', 'block');  
        var modalHeight=$(window).height() / 2 - $('#code1_code .modal-dialog').height() / 2;  
        $(this).find('.modal-dialog').css({  
            'margin-top': modalHeight  
        });
    });
    $('#code2_code').on('show.bs.modal', function (event) {
        $(this).css('display', 'block');  
        var modalHeight=$(window).height() / 2 - $('#code2_code .modal-dialog').height() / 2;  
        $(this).find('.modal-dialog').css({  
            'margin-top': modalHeight  
        });
    });
    $('#code3_code').on('show.bs.modal', function (event) {
        $(this).css('display', 'block');  
        var modalHeight=$(window).height() / 2 - $('#code3_code .modal-dialog').height() / 2;  
        $(this).find('.modal-dialog').css({  
            'margin-top': modalHeight  
        });
    });
    getTimeNow();
});

function getTimeNow() {
    var dateObj = new Date();
    var year = dateObj.getFullYear();//年
    var month = dateObj.getMonth()+1;//月  (注意：月份+1)
    var date = dateObj.getDate();//日
    var day = dateObj.getDay();
    var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
    var week = weeks[day];//根据day值，获取星期数组中的星期数。
    var hours = dateObj.getHours();//小时
    var minutes = dateObj.getMinutes();//分钟
    var seconds = dateObj.getSeconds();//秒
    if(month<10){
        month = "0"+month;
    }
    if(date<10){
        date = "0"+date;
    }
    if(hours<10){
        hours = "0"+hours;
    }
    if(minutes<10){
        minutes = "0"+minutes;
    }
    if(seconds<10){
        seconds = "0"+seconds;
    }
    var newDate = year+"年"+month+"月"+date+"日"+"&nbsp &nbsp"+week+"<br/>"+hours+":"+minutes+":"+seconds;
    $("#timeNow").html(newDate);
    setTimeout('getTimeNow()', 500);
}